<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
	<%@ taglib prefix='sec' uri='http://www.springframework.org/security/tags'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript" src="scripts/boot.js"></script>
<style type="text/css">
	ul{
		margin-left:25;padding:0;
 		list-style:none; 
	}
	.mini-checkboxlist-item{
		padding: 10px;
	}
	.ititle{
		font-size: medium;
		font-weight: bold;
	}
	.ftitle{
    font-size:14px;
    font-weight:bold;
    padding:5px 0;
    margin-bottom:10px;
    border-bottom:1px solid #ccc;
	}
	.fitem{
		margin-bottom:2px;
	}
	.fitem label{
	    display:inline-block;
	    text-align:right;
	    width: 22%;
	}
</style>
</head>
<body style="border: 0px; margin: 0px; padding: 0px;width: 100%;height: 100%">
	<div id="datagrid1" class="mini-datagrid" showPager="false" onlyCheckSelection="true" idField="id" allowCellWrap="true" url="customer_health_view.do" style="width:100%;height:auto;">
		<div property="columns">
			<div type="indexcolumn" width="15"></div>
			<div field="healthSymptomName" width="50" headerAlign="center" align="center">症状</div>
			<div field="description" width="250" headerAlign="center" align="left">描述</div>
			<div field="attendantName" width="50" headerAlign="center" align="center">座席</div>
			<div field="createTime" width="70" headerAlign="center" align="center" dateFormat="yyyy-MM-dd HH:mm:ss">添加时间</div>
			<sec:authorize url='/customer_health_del.do'>
			<div name="action" width="30" headerAlign="center" align="center" renderer="onActionRenderer" cellStyle="padding:0;">操作</div>
			</sec:authorize>
		</div>
	</div>
	<fieldset style="border:solid 1px #aaa;padding:3px;">
		<legend >添加健康档案</legend>
		<input id="customer_id" class="mini-hidden" />
		<div id="form1">
	        <table cellspacing="10" cellpadding="0">
		        <tr>
		        	<td>健康类别：</td>
		        	<td>
		        		<input name="healthArchiveId" emptyText="请选择健康类别" style="width: 150px;" required="true" class="mini-buttonedit" onbuttonclick="onButtonEdit"/>
		        	</td>
		        	<td>描述：</td>
		        	<td>
		        		<input class="mini-textbox" name="description" style="width: 500px;" required="true"/>
		        	</td>
		        	<td>
		        		<sec:authorize url='/customer_health_save.do'>
		        		<a class="mini-button" onclick="onOk" style="width:50px;">添加</a>
		        		</sec:authorize>
		        	</td>
		        </tr>
	    	</table>
		</div>
	</fieldset>
	<fieldset style="border:solid 1px #aaa;padding:3px 10px;">
		<legend >健康测试</legend>
		<div id="health_test">
		<div>
			<span class="ititle">身高、体重</span>
			身体质量指数（BMI）= 体重（kg）÷ 身高（m）²
		</div>
		<div class="fitem">
			<label>体重（kg）：</label><input id="input1" class="mini-textbox" vtype="float" style="width: 120px;"/>
			<label>身高（m）：</label><input id="input2" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div><br />
		<div>
			<span class="ititle">腰围（cm）</span>
		</div>
		<div class="fitem">
			<label>男性腰围（cm）：</label><input id="input3" class="mini-textbox" vtype="float" style="width: 120px;"/>
			<label>女性腰围（cm）：</label><input id="input4" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div><br />
		<div>
			<span class="ititle">体温（℃）</span>
		</div>
		<div class="fitem">
			<label>体温（℃）：</label><input id="input5" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div><br />
		<div>
			<span class="ititle">血压（mmHg）</span>
			理想收缩压 = (104 + (0.3 × 年龄 ) ) × 1mmHg&nbsp;&nbsp;
			理想舒张压 = (70  + (0.2 × 年龄 ) ) × 1mmHg
		</div>
		<div class="fitem">
			<label>收缩压（mmHg）：</label><input id="input6" class="mini-textbox" vtype="float" style="width: 120px;"/>
			<label>舒张压（mmHg）：</label><input id="input7" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div><br />
		<div>
			<span class="ititle">血糖（mmol/L）</span>
		</div>
		<div class="fitem">
			<label>空腹（mmol/L）：</label><input id="input8" class="mini-textbox" vtype="float" style="width: 120px;"/>
			<label>餐后两小时（mmol/L）：</label><input id="input9" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div><br />
		<div>
			<span class="ititle">血常规</span>
		</div>
		<div class="fitem">
			<label>白血球（10^9/L，成人）：</label><input id="input10" class="mini-textbox" vtype="float" style="width: 120px;"/>
			<label>白血球（10^9/L，新生儿）：</label><input id="input11" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div>
		<div class="fitem">
			<label>粒细胞百分比：</label><input id="input12" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div>
		<div class="fitem">
			<label>淋巴细胞百分比：</label><input id="input13" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div>
		<div class="fitem">
			<label>红血球（10^12/L，男性）：</label><input id="input14" class="mini-textbox" vtype="float" style="width: 120px;"/>
			<label>红血球（10^12/L，女性）：</label><input id="input15" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div>
		<div class="fitem">
			<label>血红蛋白（g/L，男性）：</label><input id="input16" class="mini-textbox" vtype="float" style="width: 120px;"/>
			<label>血红蛋白（g/L，女性）：</label><input id="input17" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div>
		<div class="fitem">
			<label>血小板（10^9/L）：</label><input id="input18" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div>
		<div>
			<span class="ititle">血脂</span>
		</div>
		<div class="fitem">
			<label>总胆固醇（mmol /L）：</label><input id="input19" class="mini-textbox" vtype="float" style="width: 120px;"/>
			<label>甘油三酯（mmol /L）：</label><input id="input20" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div>
		<div class="fitem">
			<label>高密度脂蛋白（mmol /L）：</label><input id="input21" class="mini-textbox" vtype="float" style="width: 120px;"/>
			<label>低密度脂蛋白（mmol /L）：</label><input id="input22" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div>
		<div class="fitem">
			<label>载脂蛋白（mmol /L）：</label><input id="input23" class="mini-textbox" vtype="float" style="width: 120px;"/>
			<label>载脂蛋白B（mmol /L）：</label><input id="input24" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div>
		<div>
			<span class="ititle">心率</span>
		</div>
		<div class="fitem">
			<label>心率（次/分）：</label><input id="input25" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div>
		<div>
			<span class="ititle">脉搏</span>
		</div>
		<div class="fitem">
			<label>脉搏（次/分，成人）：</label><input id="input26" class="mini-textbox" vtype="float" style="width: 120px;"/>
			<label>脉搏（次/分，青少年）：</label><input id="input27" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div>
		<div>
			<span class="ititle">尿常规</span>
		</div>
		<div class="fitem">
			<label>PH值：</label><input id="input28" class="mini-textbox" vtype="float" style="width: 120px;"/>
			<label>尿蛋白：</label><input id="input29" class="mini-combobox" style="width:120px;" textField="text" valueField="id" data="[{id:1,text:'阴性'},{id:2,text:'阳性'}]"
    allowInput="false"/>
		</div>
		<div class="fitem">
			<label>尿白细胞：</label><input id="input30" class="mini-combobox" style="width:120px;" textField="text" valueField="id" data="[{id:1,text:'阴性'},{id:2,text:'阳性'}]"
    allowInput="false"/>
			<label>尿糖：</label><input id="input31" class="mini-combobox" style="width:120px;" textField="text" valueField="id" data="[{id:1,text:'阴性'},{id:2,text:'阳性'}]"
    allowInput="false"/>
		</div>
		<div class="fitem">
			<label>胆红素：</label><input id="input32" class="mini-combobox" style="width:120px;" textField="text" valueField="id" data="[{id:1,text:'阴性'},{id:2,text:'阳性'}]"
    allowInput="false"/>
			<label>尿隐血：</label><input id="input33" class="mini-combobox" style="width:120px;" textField="text" valueField="id" data="[{id:1,text:'阴性'},{id:2,text:'阳性'}]"
    allowInput="false"/>
		</div>
		<div class="fitem">
			<label>尿酮体：</label><input id="input34" class="mini-combobox" style="width:120px;" textField="text" valueField="id" data="[{id:1,text:'阴性'},{id:2,text:'阳性'}]"
    allowInput="false"/>
		</div>
		<div>
			<span class="ititle">肝功能</span>
		</div>
		<div class="fitem">
			<label>丙氨酸氨基转移酶：</label><input id="input35" class="mini-textbox" vtype="float" style="width: 120px;"/>
			<label>总胆红素：</label><input id="input36" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div>
		<div class="fitem">
			<label>直接胆红素：</label><input id="input37" class="mini-textbox" vtype="float" style="width: 120px;"/>
			<label>间接胆红素：</label><input id="input38" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div>
		<div>
			<span class="ititle">肾功能</span>
		</div>
		<div class="fitem">
			<label>尿素氮：</label><input id="input39" class="mini-textbox" vtype="float" style="width: 120px;"/>
			<label>血尿酸：</label><input id="input40" class="mini-textbox" vtype="float" style="width: 120px;"/>
		</div>
		<div style="text-align:center;padding-top: 20px;">
			<sec:authorize url='/call_heath_result.do'>
		    <a class="mini-button" onclick="sub();" style="width:100px;margin-right:20px;">提交健康测试</a>    
		    </sec:authorize>   
		</div>
		</div>
	</fieldset>
<script type="text/javascript">
	mini.parse();
	var grid = mini.get("datagrid1");
	var form1 = new mini.Form("form1");
	var cId = mini.get("customer_id");
	function SetData(data) {
		data = mini.clone(data);
		cId.setValue(data.customerId);
		grid.load({customerId: data.customerId});
	}
	
	// 相关操作
	function onActionRenderer(e) {
		var record = e.record;
		var uid = record._uid;
		return '<a class="New_Button" href="javascript:del(\'' + uid + '\')">删除</a>';
	}
	
	// 删除
	function del(row_uid) {
		var row = grid.getRowByUID(row_uid);
		if (row) {
            if (confirm("确定删除此记录？")) {
                grid.loading("删除中，请稍后......");
                $.ajax({
                    url: "customer_health_del.do?id=" + row.id,
                    dataType: "json",
                    success: function (text) {
                    	if(text.success){
	                        grid.reload();
                   		}else{
                   			mini.alert("删除失败，id不能为空。");
                   		}
                    }
                });
            }
        }
	}
	
	// 弹出选择症状类别
	function onButtonEdit(e) {
        var btnEdit = this;
        mini.open({
            url: "customer_health_choose.do",
            title: "选择健康症状",
            width: 450,
            height: 350,
            allowResize: false,
            ondestroy: function (action) {
                //if (action == "close") return false;
                if (action == "ok") {
                    var iframe = this.getIFrameEl();
                    var data = iframe.contentWindow.GetData();
                    data = mini.clone(data);
                    if (data) {
                        btnEdit.setValue(data.id);
                        btnEdit.setText(data.name);
                    }
                }
            }
        });            
    }
	
	function onOk(){
		var o = form1.getData(true); 
	    form1.validate();
	    if (form1.isValid() == false) return;
	    $.ajax({
	        url: "customer_health_save.do?customerId=" + cId.getValue(),
			type: 'post',
			dataType: 'json',
	        data: o,
	        cache: false,
	        success: function (text) {
	            if(text.success){
	            	form1.reset();
	            	grid.load({customerId: cId.getValue()});
	            }else{
	            	mini.alert("数据错误！");
	            }
	        }
	    });
	}
	
	//提交健康测试
	var form2 = new mini.Form("health_test");
	function sub(){
		var arr = new Array();
		var t1 = mini.get("input1");
		if(t1.isValid() && t1.getFormValue()){
			var temp = "WEIGHT-"+t1.getFormValue();
			arr.push(temp);
		}
		t2 = mini.get("input2");
		if(t2.isValid() && t2.getFormValue()){
			var temp = "HEIGHT-"+t2.getFormValue();
			arr.push(temp);
		}
		t3 = mini.get("input3");
		if(t3.isValid() && t3.getFormValue()){
			var temp = "MALE_WAISTLINE-"+t3.getFormValue();
			arr.push(temp);
		}
		t4 = mini.get("input4");
		if(t4.isValid() && t4.getFormValue()){
			var temp = "FEMALE_WAISTLINE-"+t4.getFormValue();
			arr.push(temp);
		}
		t5 = mini.get("input5");
		if(t5.isValid() && t5.getFormValue()){
			var temp = "TEMPERATURE-"+t5.getFormValue();
			arr.push(temp);
		}
		t6 = mini.get("input6");
		if(t6.isValid() && t6.getFormValue()){
			var temp = "SBP-"+t6.getFormValue();
			arr.push(temp);
		}
		t7 = mini.get("input7");
		if(t7.isValid() && t7.getFormValue()){
			var temp = "DBP-"+t7.getFormValue();
			arr.push(temp);
		}
		t8 = mini.get("input8");
		if(t8.isValid() && t8.getFormValue()){
			var temp = "GLUCOSE_LIMOSIS-"+t8.getFormValue();
			arr.push(temp);
		}
		t9 = mini.get("input9");
		if(t9.isValid() && t9.getFormValue()){
			var temp = "GLUCOSE_MEAL-"+t9.getFormValue();
			arr.push(temp);
		}
		t10 = mini.get("input10");
		if(t10.isValid() && t10.getFormValue()){
			var temp = "LEUCOCYTE_ADULT-"+t10.getFormValue();
			arr.push(temp);
		}
		t11 = mini.get("input11");
		if(t11.isValid() && t11.getFormValue()){
			var temp = "LEUCOCYTE_INFANT-"+t11.getFormValue();
			arr.push(temp);
		}
		t12 = mini.get("input12");
		if(t12.isValid() && t12.getFormValue()){
			var temp = "GRAN-"+t12.getFormValue();
			arr.push(temp);
		}
		t13 = mini.get("input13");
		if(t13.isValid() && t13.getFormValue()){
			var temp = "LYMPHOCYTE-"+t13.getFormValue();
			arr.push(temp);
		}
		t14 = mini.get("input14");
		if(t14.isValid() && t14.getFormValue()){
			var temp = "RBC_MALE-"+t14.getFormValue();
			arr.push(temp);
		}
		t15 = mini.get("input15");
		if(t15.isValid() && t15.getFormValue()){
			var temp = "RBC_FEMALE-"+t15.getFormValue();
			arr.push(temp);
		}
		t16 = mini.get("input16");
		if(t16.isValid() && t16.getFormValue()){
			var temp = "HGB_MALE-"+t16.getFormValue();
			arr.push(temp);
		}
		t17 = mini.get("input17");
		if(t17.isValid() && t17.getFormValue()){
			var temp = "HGB_FEMALE-"+t17.getFormValue();
			arr.push(temp);
		}
		t18 = mini.get("input18");
		if(t18.isValid() && t18.getFormValue()){
			var temp = "PLT-"+t18.getFormValue();
			arr.push(temp);
		}
		t19 = mini.get("input19");
		if(t19.isValid() && t19.getFormValue()){
			var temp = "CHOL-"+t19.getFormValue();
			arr.push(temp);
		}
		t20 = mini.get("input20");
		if(t20.isValid() && t20.getFormValue()){
			var temp = "TRIG-"+t20.getFormValue();
			arr.push(temp);
		}
		t21 = mini.get("input21");
		if(t21.isValid() && t21.getFormValue()){
			var temp = "HDL-"+t21.getFormValue();
			arr.push(temp);
		}
		t22 = mini.get("input22");
		if(t22.isValid() && t22.getFormValue()){
			var temp = "LDL-"+t22.getFormValue();
			arr.push(temp);
		}
		t23 = mini.get("input23");
		if(t23.isValid() && t23.getFormValue()){
			var temp = "APO-"+t23.getFormValue();
			arr.push(temp);
		}
		t24 = mini.get("input24");
		if(t24.isValid() && t24.getFormValue()){
			var temp = "APOB-"+t24.getFormValue();
			arr.push(temp);
		}
		t25 = mini.get("input25");
		if(t25.isValid() && t25.getFormValue()){
			var temp = "HR-"+t25.getFormValue();
			arr.push(temp);
		}
		t26 = mini.get("input26");
		if(t26.isValid() && t26.getFormValue()){
			var temp = "PULSE_ADULT-"+t26.getFormValue();
			arr.push(temp);
		}
		t27 = mini.get("input27");
		if(t27.isValid() && t27.getFormValue()){
			var temp = "PULSE_YOUTH-"+t27.getFormValue();
			arr.push(temp);
		}
		t28 = mini.get("input28");
		if(t28.isValid() && t28.getFormValue()){
			var temp = "URINALYSIS_PH-"+t28.getFormValue();
			arr.push(temp);
		}
		t29 = mini.get("input29");
		if(t29.isValid() && t29.getFormValue()){
			var temp = "PRO-"+t29.getFormValue();
			arr.push(temp);
		}
		t30 = mini.get("input30");
		if(t30.isValid() && t30.getFormValue()){
			var temp = "LEU-"+t30.getFormValue();
			arr.push(temp);
		}
		t31 = mini.get("input31");
		if(t31.isValid() && t31.getFormValue()){
			var temp = "GLU-"+t31.getFormValue();
			arr.push(temp);
		}
		t32 = mini.get("input32");
		if(t32.isValid() && t32.getFormValue()){
			var temp = "BIL-"+t32.getFormValue();
			arr.push(temp);
		}
		t33 = mini.get("input33");
		if(t33.isValid() && t33.getFormValue()){
			var temp = "BLD-"+t33.getFormValue();
			arr.push(temp);
		}
		t34 = mini.get("input34");
		if(t34.isValid() && t34.getFormValue()){
			var temp = "KET-"+t34.getFormValue();
			arr.push(temp);
		}
		t35 = mini.get("input35");
		if(t35.isValid() && t35.getFormValue()){
			var temp = "ALT-"+t35.getFormValue();
			arr.push(temp);
		}
		t36 = mini.get("input36");
		if(t36.isValid() && t36.getFormValue()){
			var temp = "T_BIL-"+t36.getFormValue();
			arr.push(temp);
		}
		t37 = mini.get("input37");
		if(t37.isValid() && t37.getFormValue()){
			var temp = "DBILI-"+t37.getFormValue();
			arr.push(temp);
		}
		t38 = mini.get("input38");
		if(t38.isValid() && t38.getFormValue()){
			var temp = "IBILI-"+t38.getFormValue();
			arr.push(temp);
		}
		t39 = mini.get("input39");
		if(t39.isValid() && t39.getFormValue()){
			var temp = "BUN-"+t39.getFormValue();
			arr.push(temp);
		}
		t40 = mini.get("input40");
		if(t40.isValid() && t40.getFormValue()){
			var temp = "BUA-"+t40.getFormValue();
			arr.push(temp);
		}
		form2.validate();
	    if (form2.isValid() == false) return;
		var results = arr.join("|");
		$.post("call_heath_result.do",{results:results},function(data){
			mini.open({
		        url: "call_heath_view.do",
		        allowResize:false,
		        title: "健康体检报告", width: 600, height: 500,
		        onload: function () {
		            var iframe = this.getIFrameEl();
		            iframe.contentWindow.SetData(data);
		        }
		    });
		},"json");
	}
</script>
</body>
</html>